package com.hydl.power.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.hydl.power.pojo.TempData;
import com.hydl.power.service.TempDataService;
import com.hydl.power.utils.Resp;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

/**
 * @author Miss
 * @description 变压器温控数据
 * @date 2023-01-07
 */
@RestController
@RequestMapping(value = "/tempDate")
@Api(value = "TempDataController", tags = "变压器温控数据管理")
@CrossOrigin
public class TempDataController {

    @Autowired
    private TempDataService tempDataService;

    /**
     * 查询变压器温控数据
     *
     * @author Miss
     * @date 2023/01/07
     **/
    @ApiOperation("查询变压器温控数据")
    @PostMapping("/queryTempData")
    @ApiImplicitParams({@ApiImplicitParam(paramType = "query", name = "deviceId", value = "设备编码", defaultValue = "", dataType = "String"),
        @ApiImplicitParam(paramType = "query", name = "time", value = "时间", defaultValue = "2023-01-14", dataType = "String"),
        @ApiImplicitParam(paramType = "query", name = "dataType", value = "类型", defaultValue = "", dataType = "String"),
        @ApiImplicitParam(paramType = "query", name = "minute", value = "分", defaultValue = "10", dataType = "String"),})
    public Resp queryTempData(String deviceId, String time, String dataType, String minute) {
        return Resp.success(tempDataService.queryTempData(deviceId, time, dataType, minute));
    }

    @ApiOperation("温度折线图")
    @PostMapping("/getTempDataLine")
    @ApiImplicitParams({
        @ApiImplicitParam(paramType = "query", name = "deviceId", value = "设备sn", dataType = "String",defaultValue = "1001_3_1"),
        @ApiImplicitParam(paramType = "query", name = "time", value = "时间", dataType = "String",defaultValue = "2023-01-29"),
    })
    public Resp getTempDataLine(String deviceId, String time) {
        List<TempData> tempDataList = tempDataService.getTempDataLine(deviceId, time);
        return Resp.success(tempDataList);
    }
}